From 36999e2bf9ba2704d87cffe3d59dc292a1e67a19 Mon Sep 17 00:00:00 2001 From: Platonides Date: Sat, 26 Feb 2011 22:30:41 +0000 Subject: [PATCH] Disable the old conversion from Windows-1252 unless the wiki has $wgLegacyEncoding set. Has been done since r6920 (code added in r4438). Also skipping the hashing if the windows-1252 password is the same we already probed. The function_exists is not needed, since in such case GlobalFunctions would make it a wrapper to Fallback::iconv() --- RELEASE-NOTES | 3 +++ includes/User.php | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b74a8bd61b..7420e2256c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -42,6 +42,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN by the page, but $wgAllowUserJs is set to false. * Pure "Skin" class based custom skins are no longer supported, all custom skins should be put together using SkinTemplate and BaseTemplate or QuickTemplate. +* The transliteration for passwords in case they were migrated from an old Latin-1 + install (previous to MediaWiki 1.5) is now only done for wikis with + $wgLegacyEncoding set. === New features in 1.18 === * Added a special page, disabled by default, that allows users with the diff --git a/includes/User.php b/includes/User.php index 4ae4042044..20aa43e01e 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2794,7 +2794,7 @@ class User { * @return Boolean: True if the given password is correct, otherwise False. */ function checkPassword( $password ) { - global $wgAuth; + global $wgAuth, $wgLegacyEncoding; $this->load(); // Even though we stop people from creating passwords that @@ -2817,11 +2817,13 @@ class User { } if ( self::comparePasswords( $this->mPassword, $password, $this->mId ) ) { return true; - } elseif ( function_exists( 'iconv' ) ) { + } elseif ( $wgLegacyEncoding ) { # Some wikis were converted from ISO 8859-1 to UTF-8, the passwords can't be converted # Check for this with iconv $cp1252Password = iconv( 'UTF-8', 'WINDOWS-1252//TRANSLIT', $password ); - if ( self::comparePasswords( $this->mPassword, $cp1252Password, $this->mId ) ) { + if ( $cp1252Password != $password && + self::comparePasswords( $this->mPassword, $cp1252Password, $this->mId ) ) + { return true; } } -- 2.20.1